var t = getApp();

Page({
    data: {
        info: {},
        keyword: "",
        page: 1,
        is_open: 1
    },
    onLoad: function(t) {
        wx.setNavigationBarTitle({
            title: "供应商列表"
        }), this.getClass();
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        });
    },
    goUrl: function(t) {
        var a = t.currentTarget.dataset.url;
        wx.navigateTo({
            url: a
        });
    },
    goShop: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageA/member/supplier/SupplierShop/SupplierShop?id=" + a
        });
    },
    tabrshowbtn: function(t) {
        t.detail && this.setData({
            kFootshow: !1
        });
    },
    tapinp: function(t) {
        var a = t.detail.value;
        this.setData({
            keyword: a,
            page: 1
        });
    },
    tapConfirm: function() {
        this.getClass();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.current_page >= this.data.last_page || (this.setData({
            page: this.data.page + 1
        }), this.getClassMore());
    },
    onShareAppMessage: function() {
        return {
            title: this.data.info.share ? this.data.info.share.share_title : "",
            imageUrl: this.data.info.share ? this.data.info.share.share_img : "",
            path: "packageA/member/supplier/SupplierIndex/SupplierIndex"
        };
    },
    onShareTimeline: function() {
        return {
            title: this.data.info.share ? this.data.info.share.share_title : "",
            imageUrl: this.data.info.share ? this.data.info.share.share_img : "",
            path: "packageA/member/supplier/SupplierIndex/SupplierIndex"
        };
    },
    getClass: function() {
        var a = this;
        wx.showLoading({
            title: "加载中"
        });
        var e = t.getNetAddresss("plugin.supplier.frontend.shop.index.getSupplierList"), i = {
            keyword: this.data.keyword,
            page: this.data.page
        };
        t._getNetWork({
            url: e,
            data: i,
            success: function(t) {
                wx.hideLoading({
                    success: function(t) {}
                });
                var e = t.data;
                1 == e.result ? (e.data.is_open || wx.showToast({
                    title: "插件未开启",
                    icon: "none",
                    duration: 2e3,
                    success: function(t) {
                        setTimeout(function() {
                            wx.redirectTo({
                                url: "/packageG/index/index"
                            });
                        }, 2e3);
                    }
                }), a.setData({
                    is_open: e.data.is_open,
                    info: e.data,
                    listData: e.data.list.data,
                    current_page: e.data.list.current_page,
                    last_page: e.data.list.last_page
                })) : wx.showToast({
                    title: e.msg
                });
            }
        });
    },
    getClassMore: function() {
        var a = this;
        wx.showLoading({
            title: "加载中"
        });
        var e = t.getNetAddresss("plugin.supplier.frontend.shop.index.getSupplierList"), i = {
            keyword: this.data.keyword,
            page: this.data.page
        };
        t._getNetWork({
            url: e,
            data: i,
            success: function(t) {
                wx.hideLoading({
                    success: function(t) {}
                });
                var e = t.data;
                1 == e.result ? a.setData({
                    listData: a.data.listData.concat(e.data.list.data),
                    current_page: e.data.list.current_page,
                    last_page: e.data.list.last_page
                }) : wx.showToast({
                    title: e.msg
                });
            }
        });
    }
});